<?php
session_start();
require_once ( 'inc/function.php' );

$smarty = new Smarty;

$DB = NewADOConnection('mysql');
$DB->Connect('localhost', $sql_user, $sql_pass, $sql_dbase);

$login = $_SESSION['login'];

log_check($login);

if(array_key_exists('action', $_GET)){

$action = $_GET['action'];

  if ($action == "edit"){
    $smarty->assign('action', "edit");
    $id = $_GET['id'];
    $account_data = $DB->GetRow("SELECT id, login FROM users WHERE id='$id'");
    print_pre($account_data);
  }

  if ($action == "del"){
    $smarty->assign('action', "del");
    $id = $_GET['id'];
    $ok = $DB->Execute("DELETE FROM users WHERE id='$id'");
  }
}


$accounts = $DB->GetAssoc("SELECT id, login FROM users");
// print_pre($accounts);

$smarty->assign('accounts', $accounts);
$self = basename($_SERVER['PHP_SELF']);
$smarty->assign('self', $self);

$smarty->display('edit_account.tpl');

?>
